<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model_model extends MY_Model {

	var $table = 'model_manage';
	
	//构造函数
	public function __construct() {
		//调用父类构造函数，必不可少
		parent::__construct();
	}

	/**
	 * 取得所有模块
	 * 
	 * @param array $config
	 * @param array $like
	 * @return array
	 */
	public function getModelAll($config = array(), $like = array()) {
		$config['totalCount'] = $this->get_search_num(NULL, $like);
		if(isset($config['offset']) && $config['offset'] >= $config['totalCount']) {
			$config['offset'] = 0;
			$config['pageNum'] = 1;
 		}
		$config['data'] = $this->search(NULL, $config, $like);
		return $config;
	}

	/**
	 * 增加模块
	 * 
	 * @param array $data
	 * @return integer
	 */
	public function addModel($data) {
		return $this->insert($data);
	}

	/**
	 * 删除模块
	 * 
	 * @param string $ids 多个用逗号隔开
	 * @return integer
	 */
	public function deleteModel($ids) {
		$idsArr = explode(',', $ids);
		return $this->delete(array('id'=>$idsArr));
	}

	/**
	 * 更新模块信息
	 * 
	 * @param array $data
	 * @param integer $id
	 * @return integer
	 */
	public function updateModel($data, $id) {
		return $this->update($data, array('id'=>$id));
	}

	/**
	 * 查找详细信息
	 * 
	 * @param integer $id
	 * @return array
	 */
	public function findModel($id) {
		return $this->get_row(array('id'=>$id));
	}
	
	
}
